package com.nchu.learn.netty.enums;

import lombok.Getter;

/**
 * @author fujianjian
 * @project self-learning
 * @date 2020/1/16 10:27
 */
@Getter
public enum MessageTypeEnum {

    /**
     *
     */
    REQUEST((byte) 1),
    RESPONSE((byte) 2),
    PING((byte) 3),
    PONG((byte) 4),
    EMPTY((byte) 5),
    ;

    private byte type;

    MessageTypeEnum(byte type) {
        this.type = type;
    }

    public static MessageTypeEnum get(byte type) {
        for (MessageTypeEnum value : MessageTypeEnum.values()) {
            if (value.getType() == type) {
                return value;
            }
        }
        return EMPTY;
    }
}
